#include "..\os\kernel.h"
#include "..\common\led.h"
#include "..\common\util.h"
#include <avr/eeprom.h>

/**
 * \file main.c
 * \author Clecio Varjao and Leanne Ross
 * \date October 2007
 * \brief Application sample using the RTOS implementation
 *
 * \p This Application executes 4 PERIODIC tasks, 1 SYSTEM Task and 1 RR task.
 * \p The PERIODIC tasks executes a 'ping-pong' using the LED_D5_GREEN for the Ping() and LED_D5_RED for Pong().
 * \p The Ping() and Pong() have two steps: turn led on, and turn led off.
 * \p There is an implementation of an EVENT using a RR task to increment a number ( Producer() ), and a SYSTEM task to 'read' the buffer when it reachs an specified number.
 */

uint16_t return_time, next_time;
uint16_t *addr = 0;

const unsigned char PPP[]= {1, 5, 2, 5, 3, 5, 4, 5};
const unsigned int PT=4;


/*!
 Write to EEPROM
 */
void test1() 
{
  for(;;){
  	
	return_time = TCNT1;
	eeprom_write_word(addr++, return_time - next_time); 

	next_time = TCNT1;

    Task_Next();
  }
}



/*!
 * \brief Main task.
 *
 * This is a SYSTEM task create by the RTOS. This will be the first task executed.
 */
int main() 
{

   Task_Create(test1, 0, RR, 1);

   next_time = TCNT1;

   return 1;
}
